#include "TcpServer.hpp"
#include "Socket.hpp"
#include "log.hpp"
#include "LockGuard.hpp"
#include "Http.hpp"

#include <iostream>
#include <string>
#include <functional>

void Usage(char *argv[])
{
    printf("%s\n\t[Port]", argv[0]);
}

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        Usage(argv);
        exit(1);
    }
    uint16_t port = htons(std::stoi(argv[1]));
    HttpServer httpServer;
    tcpServer tcpServer(port, std::bind(&HttpServer::httpResponse, &httpServer, std::placeholders::_1, std::placeholders::_2));

    tcpServer.serverLoop();


    return 0;
}